package hyc;

import java.util.*;
public class ATM {

	public int id[];
	public double balance[];
	public int Id;
	public ATM(){
		id=new int[10];
		balance=new double[10];
		for(int i=0;i<10;i++)
		{
			id[i]=i+100;
			balance[i]=100;
		}
	}
	public double getBalance(){
		return balance[Id-100];
	}
	public void withDraw(){
		Scanner input1=new Scanner(System.in);
		double x=input1.nextDouble();
		balance[Id-100]=balance[Id-100]-x;
		System.out.println("have been withdrawn\n"+"the balance now is"+balance[Id-100]+"\n");
	}
    public void desposit(){
    	Scanner input2=new Scanner(System.in);
		double x=input2.nextDouble();
		balance[Id-100]=balance[Id-100]+x;
		System.out.println("have been desposited\n"+"the balance now is"+balance[Id-100]+"\n");
	}
	public void enter(){
		System.out.println("Enter The Id");
		Scanner input3=new Scanner(System.in);
		Id=input3.nextInt();
		int judge=0;
		for(int i=0;i<10;i++)
		{
			if(id[i]==Id)
				{
				judge=1;
				choice();
				}
		}
		if(judge==0)
		{
				System.out.println("wrong id,enter agian");
				enter();
		}
	}
	public void choice(){
		System.out.println("Main menu\n"+"1:check balance\n"+"2:withdraw\n"+"3:deposit\n"+"4:exit\n"+"Enter a choice");
		Scanner input=new Scanner(System.in);
		int choice=input.nextInt();
		switch(choice){
		case 1:
		    {System.out.println("the balance of "+Id+" is "+getBalance()+"\n");
		    break;}
		case 2:{
			withDraw();
			break;}
		case 3:{
			desposit();
			break;}
		case 4:
			{enter();
			break;
			}
		}
		choice();
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ATM run=new ATM();
		run.enter();
	}

}
